package com.sa35.fbs.controller;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.sa35.fbs.vo.UserVO;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController extends BaseController{
	
	/**
	 * Simply selects the home view to render by returning its name.
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Locale locale, Model model,HttpServletRequest request) {
		logger.info("Welcome home! The client locale is {}.", locale);
		
		UserVO user = getSessionUser(request);
		if(user!=null){
			model.addAttribute("userName", user.getUserName() );
		}else{
			model.addAttribute("userName", "Guest" );
		}
		return "home";
	}
	
	@RequestMapping(value = "create", method = RequestMethod.GET)
	public String createBooking(Model model){
		return "create_booking";
	}
	
	@RequestMapping(value = "create", method=RequestMethod.POST)
	public String submitCreateBooking(HttpServletRequest request){
		logger.info(request.getParameter("bookingName"));
		return "home";
	}
	
}
